package pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.utils;

import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.Individual;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.genetic.GeneticAlgorithmSchema;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.genetic.SGA;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.rankers.DeceptiveOneMax;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.rankers.IndividualRanker;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.terminators.FixedNumberOfIterations;
import pl.wroc.uni.ii.pastuszka.algorithms.evolutionary.terminators.LackOfImprovement;

public class Test {

  public static void AlgorithmTest(GeneticAlgorithmSchema algorithm, IndividualRanker ranker, int iterations) {
    Individual best = algorithm.run(ranker, new FixedNumberOfIterations(iterations));
    System.out.println(best);
    System.out.println(best.rank);
  }

  public static void AlgorithmTest2(GeneticAlgorithmSchema algorithm, IndividualRanker ranker) {
    Individual best = algorithm.run(ranker, new LackOfImprovement(20));
    System.out.println(best);
    System.out.println(best.rank);
  }

  /**
   * @param args
   */
  public static void main(String[] args) {
    // Test.AlgorithmTest(new PBIL(600, 60, 0.085f, 0.03f, 0.01f), new OneMax(),
    // 400);
    // Test.AlgorithmTest(new SSGA(600, 150, 8), new OneMax(), 150);
    // Test.AlgorithmTest(new SSGA(600, 60, 6), new DeceptiveOneMax(4), 200);
    // Test.AlgorithmTest2(new PBIL(600, 60, 0.085f, 0.03f, 0.01f), new
    // OneMax());
    // Test.AlgorithmTest2(new SGA(600, 60, 0.88f, 0.006f), new OneMax());
    Test.AlgorithmTest2(new SGA(600, 60, 1f, 0.005f), new DeceptiveOneMax(4));
  }
}
